package com.atguigu.acyjl;

import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.Button;

import java.util.Random;

public class OpeningAnimation {
    public void openAnimation(Button... button) {
        Random random = new Random();
        int rad_index;
        int[] delayTime = new int[]{0,75,125,175,200,250,350,450};


        ScaleAnimation[] animationWord3 = new ScaleAnimation[button.length];//动画数组
//      animationWord3 = AnimationUtils.loadAnimation(this, R.anim.open_scale);、、this错！！！！！！！！！！

        for (int i = 0; i <button.length; i++) {
            animationWord3[i] = new ScaleAnimation(0, 1, 0, 1,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            rad_index = random.nextInt(delayTime.length);
            animationWord3[i].setDuration(500);
            animationWord3[i].setStartOffset(delayTime[rad_index]);//此起彼伏效果
            button[i].startAnimation(animationWord3[i]);
        }

    }
}
